﻿#ifndef MATRIXTEST_H
#define MATRIXTEST_H

#include <QMatrix>
#include <QWidget>

#include <QPainter>
#include <QPaintEvent>
#include <QWheelEvent>
#include <QMouseEvent>

QT_BEGIN_NAMESPACE
namespace Ui { class MatrixTest; }
QT_END_NAMESPACE

class MatrixTest : public QWidget
{
    Q_OBJECT

public:
    MatrixTest(QWidget *parent = nullptr);
    ~MatrixTest();

protected:
    virtual void paintEvent(QPaintEvent *event) override;
    virtual void wheelEvent(QWheelEvent *event) override;
    
    virtual void mousePressEvent(QMouseEvent *event) override;
    virtual void mouseMoveEvent(QMouseEvent *event) override;
    virtual void mouseReleaseEvent(QMouseEvent *event) override;

private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

private:
    void drawImage(QPainter& painter);
    void drawSelectRect(QPainter& painter);
    /**
     * @brief roationImage 旋转图片
     * @param bFlag true:顺时针 false:逆时针
     */
    void roationImage(const bool& bFlag);

private:
    Ui::MatrixTest *ui;
    QImage          m_srcImage;
    QImage          m_rotationImage;
    QImage          m_drawImage;
    QRect           m_drawRect;
    QMatrix         m_matrix;
    int             m_iRotationAngle = 0;
    float           m_fZoom         = 1.f;
    QPoint          m_offset        = QPoint(0,0);

    // 鼠标点击
    QPoint          m_mousePress;
    bool            m_bMousePress;

    QRect           m_selectRect;
};
#endif // MATRIXTEST_H
